using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using SapaFinance.Domain.Model;

namespace SapaFinance.Domain.EntityFramework
{
    internal class ShareConfiguration : EntityTypeConfiguration<Share>
    {
        public ShareConfiguration()
        {
            ToTable(typeof(Share).Name.ToLower());
            HasKey(x => x.UID);
            Property(x => x.UID).HasColumnName("id").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            HasRequired(p => p.Amount).WithMany().Map(m => m.MapKey("moneyid")).WillCascadeOnDelete(false);
            HasRequired(p => p.Request).WithMany(x=>x.PartialPayment).Map(m => m.MapKey("requestid")).WillCascadeOnDelete(false);
            HasRequired(p => p.Order).WithMany(x=>x.PartialPayment).Map(m => m.MapKey("orderid")).WillCascadeOnDelete(true);
        }


    }
}